Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

test($compile): work around Chrome issue with reported size for <foreignObject> #15458

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Dec 1, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Fixes two (potential) test failures on Chrome 53-57+.

What is the current behavior? (You can also link to an open issue here)
These tests can fail on Chrome, because the reported size of the inner divs is subject to global display settings (e.g. font size) and browser settings (e.g. default zoom level).
See also #15333.

What is the new behavior (if this is a feature change)?
The assertions are now more robust by comparing against the size of the equivalent, hand-written SVG instead of fixed widths/heights.

Does this PR introduce a breaking change?
No.

Please check if the PR fulfills these requirements

Other information:
Fixes #15333

…eignObject>`

Since Chrome 53-57+, the reported size of `<foreignObject>` elements and their
descendants is affected by global display settings (e.g. font size) and browser
settings (e.g. default zoom level). This could cause tests incorrectly failing
due to such settings.

In order to avoid false negatives, we now compare against the size of the
equivalent, hand-written SVG instead of fixed widths/heights.

Fixes angular#15333

expect(isHTMLElement(testElem)).toBe(true);
expect(referenceBounds.width).toBeGreaterThan(0);
expect(referenceBounds.height).toBeGreaterThan(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to believe that this might not be greater than zero?
And even if it was zero, do we care? If that is what the browser does with the handwritten HTML then so be it?
Right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just a sanity check that we are doing the right thing and the hand-written HTML produces something. If this changes in the future (e.g. the hand-written HTML does not produce the expected result) and we break $compile, the tests might pass although the code will be broken.
It is a somewhat far fetched scenario, so I can remove it if you think it is more confusing than helpful.

@petebacondarwin
Copy link
Contributor

A minor comment but LGTM, with or without changes.

Narretz pushed a commit to Narretz/angular.js that referenced this pull request Dec 1, 2016
…eignObject>`

Since Chrome 53-57+, the reported size of `<foreignObject>` elements and their
descendants is affected by global display settings (e.g. font size) and browser
settings (e.g. default zoom level). This could cause tests incorrectly failing
due to such settings.

In order to avoid false negatives, we now compare against the size of the
equivalent, hand-written SVG instead of fixed widths/heights.

Fixes angular#15333

Closes angular#15458
@Narretz
Copy link
Contributor

Narretz commented Dec 1, 2016

These tests also fail on Edge 14, but this patch fixes it (tested locally)

@gkalpak gkalpak closed this in 9c2d0b8 Dec 1, 2016
@gkalpak gkalpak deleted the test-compile-account-for-Chrome-foreignObject-bug branch December 1, 2016 12:34
@petebacondarwin
Copy link
Contributor

Doesn't this need to be backported @gkalpak?

gkalpak added a commit that referenced this pull request Dec 1, 2016
…eignObject>`

Since Chrome 53-57+, the reported size of `<foreignObject>` elements and their
descendants is affected by global display settings (e.g. font size) and browser
settings (e.g. default zoom level). This could cause tests incorrectly failing
due to such settings.

In order to avoid false negatives, we now compare against the size of the
equivalent, hand-written SVG instead of fixed widths/heights.

Fixes #15333

Closes #15458
@gkalpak
Copy link
Member Author

gkalpak commented Dec 1, 2016

Done! Thx :)
(I tried to backport to v1.5.x and didn't notice it failed.)

ellimist pushed a commit to ellimist/angular.js that referenced this pull request Mar 15, 2017
…eignObject>`

Since Chrome 53-57+, the reported size of `<foreignObject>` elements and their
descendants is affected by global display settings (e.g. font size) and browser
settings (e.g. default zoom level). This could cause tests incorrectly failing
due to such settings.

In order to avoid false negatives, we now compare against the size of the
equivalent, hand-written SVG instead of fixed widths/heights.

Fixes angular#15333

Closes angular#15458
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Two svg compile tests fail in Chrome 54
4 participants